package com.cy.dda.comm.job;

import java.util.Calendar;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.cy.dda.comm.utils.CommonUtils;
import com.cy.dda.service.statistics.MaintainStatisticsService;

/**
 * 定时任务，维护统计数据
 *
 * @author: tanyilin
 * @create: 2018年11月5日 上午11:38:06
 */
@Component
public class StatisticsJob {

	@Autowired
	private MaintainStatisticsService maintainStatisticsService;
	
	@Scheduled(cron = "0 0 1 * * ?")
	public void maintainStatisticsCollectionRecord() {
		Date date = new Date();
		date = CommonUtils.addTime(date, -1, Calendar.DAY_OF_YEAR);
		maintainStatisticsService.maintainStatisticsCollectionRecord(date);
	}
	
	@Scheduled(cron = "0 0 2 * * ?")
	public void maintainStatisticsRepayRecord() {
		Date date = new Date();
		date = CommonUtils.addTime(date, -1, Calendar.DAY_OF_YEAR);
		maintainStatisticsService.maintainStatisticsRepayRecord(date);
	}
}
